package cyx.example.ddd.interfaces.order.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@ApiModel("创建订单请求")
public class CreateOrderRequest {
    @NotNull(message = "用户ID不能为空")
    @ApiModelProperty("用户ID")
    private String userId;

    @NotNull(message = "货币代码不能为空")
    @ApiModelProperty("货币代码，例如：CNY, USD")
    private String currency;

    @NotEmpty(message = "订单项不能为空")
    @Valid
    @ApiModelProperty("订单项列表")
    private List<OrderItemRequest> items;

    @Data
    @ApiModel("订单项请求")
    public static class OrderItemRequest {
        @NotNull(message = "商品ID不能为空")
        @ApiModelProperty("商品ID")
        private String productId;

        @NotNull(message = "商品名称不能为空")
        @ApiModelProperty("商品名称")
        private String productName;

        @NotNull(message = "商品单价不能为空")
        @ApiModelProperty("商品单价")
        private Double unitPrice;

        @NotNull(message = "商品数量不能为空")
        @ApiModelProperty("商品数量")
        private Integer quantity;
    }
}